package chapter6.No6_1_立即加载_饿汉模式.demo9;

import java.io.ObjectStreamException;
import java.io.Serializable;

/**
 * Created by Administrator on 2016/11/25.
 */
public class MyObject implements Serializable {

    private MyObject() {
    }

    private static class MyObjectInner {
        private static MyObject object = new MyObject();
    }

    public static MyObject getInstance() {
        return MyObjectInner.object;
    }

    protected Object readResolve() throws ObjectStreamException {
        System.out.println("调用了 readResolve()");
        return MyObjectInner.object;
    }
}
